Skip to content

refactor(Invoke-Logging): use pre-parsed scriptblock cache + add dedicated tests#77

Merged
HeyItsGilbert merged 2 commits into
mainfrom
copilot/refactor-invoke-logging-cache
May 14, 2026
Merged

refactor(Invoke-Logging): use pre-parsed scriptblock cache + add dedicated tests#77
HeyItsGilbert merged 2 commits into
mainfrom
copilot/refactor-invoke-logging-cache

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 14, 2026

Invoke-Logging was bypassing the $script:GatekeeperLogging cache built by Import-GatekeeperConfig, re-compiling scriptblocks from raw config on every rule evaluation — losing closure context for any scriptblock that had already been parsed.

Changes

  • tests/Invoke-Logging.tests.ps1 (new): Dedicated test coverage for Invoke-Logging that was previously only exercised via a mock in Test-FeatureFlag.tests.ps1. Covers:

    • Cached scriptblock is invoked with the correct $Rule when the effect is enabled
    • No invocation when the effect is absent from the cache (disabled logging level)
    • Graceful no-op when $script:GatekeeperLogging is $null or empty
    • Import-GatekeeperConfig is called on every invocation to guarantee cache initialization
  • CHANGELOG.md: [Unreleased] entry documenting the fix.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • www.powershellgallery.com
    • Triggering command: /usr/bin/pwsh pwsh -Command .\build.ps1 -Bootstrap (dns block)
    • Triggering command: /usr/bin/pwsh pwsh -Command Register-PSRepository -Default -ErrorAction SilentlyContinue; Set-PSRepository -Name PSGallery -InstallationPolicy Trusted; .\build.ps1 -Bootstrap (dns block)
    • Triggering command: /usr/bin/pwsh pwsh -Command Get-PSRepository (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Refactor Invoke-Logging to utilize pre-parsed script cache refactor(Invoke-Logging): use pre-parsed scriptblock cache + add dedicated tests May 14, 2026
Copilot AI requested a review from HeyItsGilbert May 14, 2026 00:48
@github-actions
Copy link
Copy Markdown

Test Results

    4 files    448 suites   14s ⏱️
  379 tests   374 ✅  5 💤 0 ❌
1 492 runs  1 469 ✅ 23 💤 0 ❌

Results for commit 86ffb8d.

@HeyItsGilbert HeyItsGilbert marked this pull request as ready for review May 14, 2026 01:40
@HeyItsGilbert HeyItsGilbert merged commit 90b5783 into main May 14, 2026
7 checks passed
@HeyItsGilbert HeyItsGilbert deleted the copilot/refactor-invoke-logging-cache branch May 14, 2026 01:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(Invoke-Logging): ignores pre-parsed script cache, rebuilds scriptblock on every call

2 participants